package com.gpframework.module.controller.wages;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;

import cn.hutool.core.convert.Convert;
import cn.hutool.core.lang.TypeReference;
import com.gpframework.module.wages.domain.vo.GzWarehouseWorkerSalaryLevelVo;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.gpframework.common.annotation.Log;
import com.gpframework.common.core.controller.BaseController;
import com.gpframework.common.core.domain.AjaxResult;
import com.gpframework.common.enums.BusinessType;
import com.gpframework.module.wages.domain.GzSalaryLevelTransferWarehouseWorkers;
import com.gpframework.module.wages.domain.vo.GzSalaryLevelTransferWarehouseWorkersVo;
import com.gpframework.module.wages.domain.req.GzSalaryLevelTransferWarehouseWorkersReq;
import com.gpframework.module.wages.domain.req.GzSalaryLevelTransferWarehouseWorkersAdd;
import com.gpframework.module.wages.domain.req.GzSalaryLevelTransferWarehouseWorkersUpdate;
import com.gpframework.module.wages.service.IGzSalaryLevelTransferWarehouseWorkersService;
import com.gpframework.common.utils.poi.ExcelUtil;
import javax.validation.Valid;
import io.swagger.annotations.*;
import com.gpframework.common.core.page.TableDataInfo;
/**
 * @ClassName GzSalaryLevelTransferWarehouseWorkersController
 * @Author gpframework
 * @Date 2024-01-18
 * @Version 1.0.0
 * @Description 中转仓员工资级别Controller
 */
@Validated
@Api(tags = "中转仓员工资级别")
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@SuppressWarnings({"rawtypes","unchecked"})
@RequestMapping("/wages/transferwarehouseworkersalarylevel" )
public class GzSalaryLevelTransferWarehouseWorkersController extends BaseController {

    private final IGzSalaryLevelTransferWarehouseWorkersService iGzSalaryLevelTransferWarehouseWorkersService;

    /**
     * @Description 分页
     * @Author gpframework
     * @Date 2024-01-18
     * @Param gzSalaryLevelTransferWarehouseWorkers
     * @Return TableDataInfo
     */
    @ApiOperation("列表")
    @PreAuthorize("@ss.hasPermi('wages:transferwarehouseworkersalarylevel:list')")
    @GetMapping("/list")
    public  TableDataInfo<GzSalaryLevelTransferWarehouseWorkersVo> list(GzSalaryLevelTransferWarehouseWorkersReq gzSalaryLevelTransferWarehouseWorkersReq)
    {
        startPage();
        QueryWrapper<GzSalaryLevelTransferWarehouseWorkers> lqw = new QueryWrapper<GzSalaryLevelTransferWarehouseWorkers>();
        gzSalaryLevelTransferWarehouseWorkersReq.generatorQuery(lqw,true);
        List<GzSalaryLevelTransferWarehouseWorkersVo> list = iGzSalaryLevelTransferWarehouseWorkersService.listVo(lqw);
        return getDataTable(list);
    }

    /**
     * @Description 新增
     * @Author gpframework
     * @Date 2024-01-18
     * @Param gzSalaryLevelTransferWarehouseWorkers
     * @Return TableDataInfo
     */
    @ApiOperation("新增")
    @PreAuthorize("@ss.hasPermi('wages:transferwarehouseworkersalarylevel:add')" )
    @Log(title = "添加中转仓员工资级别" , businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@Valid @RequestBody GzSalaryLevelTransferWarehouseWorkersAdd gzSalaryLevelTransferWarehouseWorkersAdd) {
        GzSalaryLevelTransferWarehouseWorkers gzSalaryLevelTransferWarehouseWorkers = Convert.convert(new TypeReference<GzSalaryLevelTransferWarehouseWorkers>() {}, gzSalaryLevelTransferWarehouseWorkersAdd);
        return toAjax(iGzSalaryLevelTransferWarehouseWorkersService.save(gzSalaryLevelTransferWarehouseWorkers) ? 1 : 0);
    }

    /**
     * @Description 修改
     * @Author gpframework
     * @Date 2024-01-18
     * @Param gzSalaryLevelTransferWarehouseWorkers
     * @Return TableDataInfo
     */
    @ApiOperation("修改")
    @PreAuthorize("@ss.hasPermi('wages:transferwarehouseworkersalarylevel:edit')" )
    @Log(title = "修改中转仓员工资级别" , businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@Valid @RequestBody GzSalaryLevelTransferWarehouseWorkersUpdate gzSalaryLevelTransferWarehouseWorkersUpdate) {
        GzSalaryLevelTransferWarehouseWorkers gzSalaryLevelTransferWarehouseWorkers = Convert.convert(new TypeReference<GzSalaryLevelTransferWarehouseWorkers>() {}, gzSalaryLevelTransferWarehouseWorkersUpdate);
        return toAjax(iGzSalaryLevelTransferWarehouseWorkersService.updateById(gzSalaryLevelTransferWarehouseWorkers) ? 1 : 0);
    }


    /**
     * @Description 导出
     * @Author gpframework
     * @Date 2024-01-18
     * @Param gzSalaryLevelTransferWarehouseWorkers
     * @Return TableDataInfo
     */

    @PreAuthorize("@ss.hasPermi('wages:transferwarehouseworkersalarylevel:export')" )
    @Log(title = "导出中转仓员工资级别" , businessType = BusinessType.EXPORT)
    @GetMapping("/export" )
    public AjaxResult export(GzSalaryLevelTransferWarehouseWorkersReq gzSalaryLevelTransferWarehouseWorkersReq) {
        QueryWrapper<GzSalaryLevelTransferWarehouseWorkers> lqw = new QueryWrapper<GzSalaryLevelTransferWarehouseWorkers>();
        gzSalaryLevelTransferWarehouseWorkersReq.generatorQuery(lqw,true);
        List<GzSalaryLevelTransferWarehouseWorkersVo> list = iGzSalaryLevelTransferWarehouseWorkersService.listVo(lqw);
        ExcelUtil<GzSalaryLevelTransferWarehouseWorkersVo> util = new ExcelUtil<GzSalaryLevelTransferWarehouseWorkersVo>(GzSalaryLevelTransferWarehouseWorkersVo. class);
        return util.exportExcel(list, "warehouseworkersalarylevel" );
    }

    /**
     * @Description 详情
     * @Author gpframework
     * @Date 2024-01-18
     * @Param gzSalaryLevelTransferWarehouseWorkers
     * @Return TableDataInfo
     */
    @ApiOperation("详情")
    @PreAuthorize("@ss.hasPermi('wages:transferwarehouseworkersalarylevel:query')" )
    @GetMapping(value = "/{id}" )
    public AjaxResult<GzSalaryLevelTransferWarehouseWorkersVo> getInfo(@PathVariable("id" ) Long id) {
        return AjaxResult.success(iGzSalaryLevelTransferWarehouseWorkersService.getVoById(id));
    }



    /**
     * @Description 删除
     * @Author gpframework
     * @Date 2024-01-18
     * @Param gzSalaryLevelTransferWarehouseWorkers
     * @Return TableDataInfo
     */
    @ApiOperation("删除")
    @PreAuthorize("@ss.hasPermi('wages:transferwarehouseworkersalarylevel:remove')" )
    @Log(title = "删除中转仓员工资级别" , businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}" )
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(iGzSalaryLevelTransferWarehouseWorkersService.removeByIds(Arrays.asList(ids)) ? 1 : 0);
    }
}
